package com.example._06servlet; /**
 * @author YAO
 * @create 2021-04-19 16:39
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

public class ContextServlet1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取ServletContext对象
        ServletContext context = getServletContext();
        System.out.println(context);

        System.out.println("保存之前数据key1的值是:" + context.getAttribute("key1"));

        context.setAttribute("key1","value1");

        System.out.println("Context1中获取数据key1的值是:" + context.getAttribute("key1"));
    }


}
